import * as ElementPlusIconsVue from "@element-plus/icons-vue"

// ElInput
const ElInputProps = ElInput.props
ElInputProps.clearable = { type: Boolean, default: true }
ElInputProps.placeholder = { type: String, default: "请输入" }
ElInputProps.maxlength = { type: Number, default: 50 }

// ElSelect
const ElSelectProps = ElSelect.props
ElSelectProps.clearable = { type: Boolean, default: true }
ElSelectProps.filterable = { type: Boolean, default: true }
ElSelectProps.placeholder = { type: String, default: "请选择" }

// ElDialog
const ElDialogProps = ElDialog.props
ElDialogProps.closeOnClickModal = { type: Boolean, default: false }
ElDialogProps.width = { type: String, default: "850px" }

// ElDrawer
const ElDrawerProps = ElDrawer.props
ElDrawerProps.closeOnClickModal = { type: Boolean, default: false }
ElDrawerProps.size = { type: String, default: "400px" }

// ElPagination
const ElPaginationProps = ElPagination.props
ElPaginationProps.pageSizes = {
  type: Array,
  default: () => {
    return [10, 20, 30, 50]
  },
}
ElPaginationProps.size = { type: Number, default: 10 }
ElPaginationProps.background = { type: Boolean, default: true }
ElPaginationProps.layout = { type: String, default: "total, sizes, prev, pager, next" }
ElPaginationProps.size = { type: String, default: "small" }

// ElDate
const ElTimePickerProps = ElTimePicker.props
const ElDatePickerProps = ElDatePicker.props
ElTimePickerProps.clearable = { type: Boolean, default: false }
ElDatePickerProps.clearable = { type: Boolean, default: false }

export function setup(app) {
  // 全局注册Icon
  for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }

  if (window) {
    window.$notify = ElNotification
    window.$message = ElMessage
    window.$confirm = (message, title, options) => {
      if (!options.closeOnClickModal) {
        options.closeOnClickModal = false
      }
      return ElMessageBox.confirm(message, title, options)
    }
    window.$alert = ElMessageBox.alert
  }
}
